<?php
define("JL", 1);
@session_start();

include ('./dbconfig.php');
require './administration/Libraries/JLAjax.class.php';

$code = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
$mode = filter_var($_POST['mode'], FILTER_SANITIZE_STRING);

$Ajax = JLAjax::getInstance();
$Ajax->checkToken();

if ($Ajax->isAjaxRequest()) {
    if ($Ajax->isValidToken() && !empty($code) && !empty($mode)) {
        $Ajax->resetToken();
        $msg = '';

        switch ($mode) {
            case 'delete':
                $sql = "DELETE FROM 
                  `tbl_suscriptores` 
                WHERE 
                  `var_code` = '" . sqlQuote($code, $cnn) . "'";
                $msg = "L'adresse e-mail suivante a été retirée de notre liste de diffusion. A bientôt.";
                break;
            case 'update':
                $email = filter_var($_POST['txtaddress'], FILTER_SANITIZE_STRING);

                if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    $sql = "UPDATE 
                      `tbl_suscriptores`
                    SET
                      `var_email` = '" . sqlQuote($email, $cnn) . "'
                    WHERE 
                      `var_code` = '" . sqlQuote($code, $cnn) . "'";
                    $msg = "Merci,\nNous avons pris en compte votre changement d'adresse e-mail.";
                } else {
                    @mysql_close($cnn);
                    $Ajax->response(RESPONSE_CODE_ERROR);
                }
                break;
        }

        $res = mysql_query($sql, $cnn);
        if (mysql_affected_rows($cnn) > 0) {
            @mysql_close($cnn);

            $Ajax->resetToken();
            $Ajax->response(RESPONSE_CODE_OK, $msg);
        } else {
            @mysql_close($cnn);
            $Ajax->response(RESPONSE_CODE_ERROR);
        }
        exit;
    } else {
        $Ajax->forbiddenHeader();
    }
} else {
    if (!empty($code)) {
        $sql = "SELECT `var_email`, var_fullname FROM `tbl_suscriptores` WHERE `var_code` = '" . sqlQuote($code, $cnn) . "'";
        $res = mysql_query($sql, $cnn);

        if (mysql_affected_rows($cnn) > 0) {
            $row = mysql_fetch_assoc($res);
            $email = $row['var_email'];
            $fullname = $row['var_fullname'];
        } else
            header("Location: ./");
    } else
        header("Location: ./");
}

function sqlQuote($value, $cnn) {
    if (get_magic_quotes_gpc())
        $value = stripslashes($value);
    if (function_exists("mysql_real_escape_string"))
        $value = mysql_real_escape_string($value, $cnn);
    else
        $value = addslashes($value);
    return $value;
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" lang="fr-FR" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="pragma" content="no-cache" />
        <meta name="robots" content="no index, no follow" />
        <meta name="google-site-verification" content="l6Fc4-_RGKeL_0Y8H7wAhDHge8ORqjoSkWeN2WQQzrU" />
        <meta name="generator" content="LBN | Design &amp; Development Studio" />
        <title>Souscription CSME</title>
        <link href="js/lib/flexslider.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <link href="base.css" rel="stylesheet" type="text/css" media="all" />
        <link href="slider/stylesheets/slider-popup.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <link href="js/lib/xpopup/xpopup-1.0.css" rel="stylesheet" type="text/css" media="screen, projection" />
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script>!window.jQuery && document.write(unescape('%3Cscript src="js/lib/jquery-1.7.1.min.js"%3E%3C/script%3E'))</script>
        <link rel="stylesheet" href="slider/stylesheets/coda-slider-2.0.css" type="text/css" media="screen" />
        <script type="text/javascript" src="slider/javascripts/jquery.coda-slider-2.0_update.js"></script>
        <script type="text/javascript" src="slider/javascripts/jquery.easing.1.3.js"></script>
        <script type="text/javascript" src="js/lib/xpopup/xpopup.min-1.0.js"></script>
        <script type="text/javascript" src="js/lib/jquery.xvalidator-1.0.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.flexslider-min.js"></script>
        <script type="text/javascript" src="js/lib/utils-1.0.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.tooltip.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery.cookie.min.js"></script>
        <script type="text/javascript" src="administration/?act=required"></script>
        <style>
            <!-- 
            /* Presentation */
            .coda-nav ul li.tab4, .coda-nav ul li.tab5{ display:none; }
            .coda-nav ul li.tab4 a,.coda-nav ul li.tab5 a{ margin-left:25px; }
            label.error {font-weight:bold; color:#C00; display:inline;}
            #error_chk {display: none;  color:#C00; }
            #msg-error {display: none; font-weight:bold; color:#C00; }
            -->
        </style>
        <!--[if IE]>
        <style>.submitimagehidden{ margin-left:160px; margin-top:43px; }</style>
        <![endif]-->
        <!--[if IE 7]>
        <link href="base-ie7.css" rel="stylesheet" type="text/css" media="screen, projection" charset="utf-8" />
        <![endif]-->
        <link rel="shortcut icon" href="favicon.ico" />
        <link rel="alternate" type="application/rss+xml" title="CSME Actualitès - RSS Feed" href="http://feed.csme.fr/" />
    </head>
    <body>

        <?php include 'modules/annonce.html.php'; ?>
        
        <div id = "button_top">
            <a href = "javascript:;"><img src = "images/arrow_top.png" width = "18" height = "25" />
                <span id = "top">TOP <br /><strong>SITE</strong></span>
            </a>
        </div>
        
        <div id="main-container">

            <!-- BN-TOP -->
            <div id="bn-top" class="bxshd">    

                <!-- MENU-TOP -->
                <div class="menu-top">

                     <div id="logo">
                        <a href="./" title="CSME Club Sportif Multisections d'Epinay-sur-Seine"><img alt="CSME LOGO" src="images/csme-logo.png" width="174" height="159" /></a>
                    </div>

                    <!-- NEWSLETTER -->
                    <div id="newsletter" class="bxshd">
                        <div class="newscenter">
                            <div class="newscontent">
                                <h3><img src="images/sobre.png" width="16" height="12" /> Newsletter</h3>
                                <div class="subtitle">Inscrivez-vous à notre newsletter.</div>
                                <div><form action="./" method="post" enctype="application/x-www-form-urlencoded" name="frmnewsletter" id="frmnewsletter">
                                        <input name="txtnom" type="text" class="txtnewsletter" id="txtnom" autocomplete="off" />
                                        <label id="email">
                                            <input name="txtemail" type="text" class="txtnewsletter" id="txtemail" autocomplete="off" />
                                            <input class="valid" type="submit" value="OK" onfocus="this.blur();" />
                                        </label>
                                    </form>
                                </div>


                                <div id="partenaires">

                                    <div class="face_fb_plugin"><a title="Suivez-nous sur facebook" target="_blank" href="http://www.facebook.com/CSMEpinaysurSeine"></a></div>
                                    <div class="text_fb_plugin">Soyez le premier parmi vos amis.
                                        <br />Rejoignez-nous vite !
                                    </div>
                                    <div class="fb_like_plugin">
                                        <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FCSME-Club-Sportif-Multisections-dEpinay-sur-Seine%2F176399182395742&amp;layout=button_count&amp;locale=fr_FR&amp;show_faces=false&amp;width=170&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:170px; height:21px;" allowTransparency="true"></iframe>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- END NEWSLETTER -->


                    <!-- MENU -->
                    <ul>
                        <li><a class="link" title="Accueil" href="./"  target="_parent">Accueil</a></li>
                        <li><a class="link" title="Présentation" href="presentation.html"  target="_parent">Présentation</a></li>
                        <li><a class="link" title="Les Sections"  target="_parent" id="les_sections_id">Les sections</a>
                            <?php
                            include_once 'modules/menu.html.php';
                            printMenu($select);
                            ?>
                        </li>
                        <li><a class="link" title="Actualités" href="actualites.html" target="_parent">Actu. CSME</a></li>
                        <li><a class="link" title="Administration" href="administration.html" target="_parent">Administration</a></li>
                        <li><a class="link" title="Contact" href="contacts.html" target="_parent">Contact</a></li>
                    </ul>
                    <!-- END MENU-->


                </div>
                <!-- END MENU-TOP -->


            </div>
            <!-- END BN-TOP -->


            <!-- BN-CONTENT-->
            <div id="bn-content">

                <!-- BN CONTENT TEXT -->
                <div class="bn-content-text bxshd">
                    <table border="0" cellpadding="0" cellspacing="0" class="bn-ct-repeat">
                        <tr>
                            <td class="bn-ct-r-center">

                                <div  style="margin:0 auto; width:600px; margin-bottom:60px;">

                                    <div class="panel">
                                        <div class="panel-wrapper">
                                            <h2 class="title" style="font-size:33px; text-align:center; display:block;">Vous ne souhaitez plus être contacté</h2>
                                            <p style="padding-top:15px;"><strong>Bonjour <?php echo $fullname; ?></strong>,<br /><br />
                                                L'adresse à laquelle vous avez choisi de recevoir les prochaines nouvelles et informations exclusives sur le CSME est : <strong><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></strong><br />
                                            </p>
                                            <div class="bn-contact" style="margin:0 auto;">
                                                <form id="frm-contact" name="frm-contact" method="post" action="?" enctype="application/x-www-form-urlencoded">
                                                    <table border="0" align="center" cellpadding="0" cellspacing="0" class="bn-c-form suscrib">
                                                        <tr>
                                                            <td align="center" valign="top" colspan="3" height="2"><label id="error_chk" for="gender" class="error">(*) S'il vous plaît sélectionnez une option.</label>
                                                                <span id="msg-error"></span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="10" align="right" valign="top"><input type="hidden" id="txtvalido" autocomplete="off" /></td>
                                                            <td width="5">&nbsp;</td>
                                                            <td width="270">&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right"><input type="radio" value="delete" name="gender" id="rdo_remove" autocomplete="off" /></td>
                                                            <td width="5">&nbsp;</td>
                                                            <td><label for="rdo_remove">Merci de me retirer de votre liste de diffusion.</label></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" style="padding-bottom:10px;"><input type="radio" value="update" name="gender" id="rdo_update" /></td>
                                                            <td width="5" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td style="padding-bottom:10px;"><label for="rdo_update">Merci de noter mon changement d'adresse e-mail :</label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" valign="top" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td width="5" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td style="padding-bottom:10px;"><input name="txtaddress" type="text" class="text" id="txtaddress" value="" autocomplete="off" /></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td style="padding-bottom:10px;">&nbsp;</td>
                                                            <td style="padding-bottom:10px;"><label>Confirmez votre adresse :</label></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td width="5" style="padding-bottom:10px;">&nbsp;</td>
                                                            <td style="padding-bottom:10px;"><input name="txtre-address" type="text" class="text" id="txtre-address" value=""  autocomplete="off" /></td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                            <td><input name="txtcivilite7" type="submit" class="button" id="txtcivilite7" value="Envoyer" size="45" /></td>
                                                        </tr>
                                                    </table>
                                                </form>
                                            </div>
                                        </div>
                                    </div>



                                </div>


                            </td>
                        </tr>
                    </table>
                    <div class="fldbtm"></div>                    
                </div>
                <!-- END CONTENT TEXT -->
                <div id="push"></div>

            </div>    
            <!-- BN-CONTENT-->
        </div>

        <div id="msg-subscription" class="msgbox">
            <div class="msg-txt">
                <strong>Merci !</strong> <br />
                <span>Vous recevrez notre newsletter avec les dernières news du CSME. A bientôt !</span>
            </div>
            <div class="line msj"></div>
        </div>

        <?php
        include 'modules/footer.html.php';
        printFooter($cnn, $select);
        printTooltips($cnn);
        @mysql_close();
        ?>  
        <script type="text/javascript" src="js/js-main.js"></script>
        <script type="text/javascript" src="js/js-form-subscription.js"></script>
    </body>
</html>